/**  
 * @Title: WsSendParam.java
 * @Package com.icss.trans.ws.put
 * @Description: TODO(用一句话描述该文件做什么)
 * @author ICSS
 * @date 2015-3-31 上午11:12:16
 * @version V1.0  
 */
package com.icss.trans.ws.put;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * @ClassName : WsSendParam
 * @Description :
 * @author ICSS
 * @date 2015-3-31 上午11:12:16
 */
public class WsSendParam {

    /**
     * @Fields sourceAppCode :
     */
    private String sourceAppCode;

    /**
     * @Fields destOrgCode :
     */
    private String destOrgCode;

    /**
     * @Fields destAppCode :
     */
    private String destAppCode;

    /**
     * @Fields dataTransType :
     */
    private String dataTransType;

    /**
     * @Fields fileContent :
     */
    private String fileContent;

    /**
     * @Fields fileName :
     */
    private String fileName;

    /**
     * @Fields key :
     */
    private String key;

    /**
     * @Description:
     */
    public WsSendParam(String sourceAppCode, String destOrgCode, String destAppCode, String dataTransType,
            String fileContent, String fileName, String key) {
        this.sourceAppCode = sourceAppCode;
        this.destOrgCode = destOrgCode;
        this.destAppCode = destAppCode;
        this.dataTransType = dataTransType;
        this.fileContent = fileContent;
        this.fileName = fileName;
        this.key = key;
    }

    public WsSendParam() {
    }

    /**
     * @Description: 
     * @param builder
     */
    private WsSendParam(Builder builder) {
        this.sourceAppCode = builder.sourceAppCode;
        this.destOrgCode = builder.destOrgCode;
        this.destAppCode = builder.destAppCode;
        this.dataTransType = builder.dataTransType;
        this.fileContent = builder.fileContent;
        this.fileName = builder.fileName;
        this.key = builder.key;
    }

    public static class Builder {

        private String sourceAppCode;

        private String destOrgCode;

        private String destAppCode;

        private String dataTransType;

        private String fileContent;

        private String fileName;

        private String key;

        public Builder sourceAppCode(String sourceAppCode) {
            this.sourceAppCode = sourceAppCode;
            return this;
        }

        public Builder destOrgCode(String destOrgCode) {
            this.destOrgCode = destOrgCode;
            return this;
        }

        public Builder destAppCode(String destAppCode) {
            this.destAppCode = destAppCode;
            return this;
        }

        public Builder dataTransType(String dataTransType) {
            this.dataTransType = dataTransType;
            return this;
        }

        public Builder fileContent(String fileContent) {
            this.fileContent = fileContent;
            return this;
        }

        public Builder fileName(String fileName) {
            this.fileName = fileName;
            return this;
        }

        public Builder key(String key) {
            this.key = key;
            return this;
        }

        /**
         * 
         * @Description: build参数对象
         * @return
         */
        public WsSendParam build() {
            if (StringUtils.isEmpty(dataTransType)) {
                throw new IllegalArgumentException("param[dataTransType] is null");
            }
            if (StringUtils.isEmpty(sourceAppCode)) {
                throw new IllegalArgumentException("param[sourceAppCode] is null");
            }
            if (StringUtils.isEmpty(destOrgCode)) {
                throw new IllegalArgumentException("param[destOrgCode] is null");
            }
            if (StringUtils.isEmpty(key)) {
                throw new IllegalArgumentException("param[key] is null");
            }
            if (StringUtils.isEmpty(fileName)) {
                throw new IllegalArgumentException("param[fileName] is null");
            }
            if (StringUtils.isEmpty(fileContent)) {
                throw new IllegalArgumentException("param[fileContent] is null");
            }
            // 如果不设置目标应用代码则默认和原一样
            if (StringUtils.isEmpty(destAppCode)) {
                destAppCode = this.sourceAppCode;
            }
            return new WsSendParam(this);
        }
    }

    public String getSourceAppCode() {
        return sourceAppCode;
    }

    public void setSourceAppCode(String sourceAppCode) {
        this.sourceAppCode = sourceAppCode;
    }

    public String getDestOrgCode() {
        return destOrgCode;
    }

    public void setDestOrgCode(String destOrgCode) {
        this.destOrgCode = destOrgCode;
    }

    public String getDestAppCode() {
        return destAppCode;
    }

    public void setDestAppCode(String destAppCode) {
        this.destAppCode = destAppCode;
    }

    public String getDataTransType() {
        return dataTransType;
    }

    public void setDataTransType(String dataTransType) {
        this.dataTransType = dataTransType;
    }

    public String getFileContent() {
        return fileContent;
    }

    public void setFileContent(String fileContent) {
        this.fileContent = fileContent;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this, obj);
    }
}